<template>
  <div class="info home-column" v-if="newsList != null">
    <home-title title="推荐资讯" @more="handleMore"></home-title>
    <el-row :gutter="26" class="info-box" v-if="newsList.length > 0">
      <el-col :span="6" v-for="(item, index) in newsList" :key="index">
        <div class="item">
          <div class="picture" @click="handlePath(item)">
            <edu-image :src="item.cover_url" fit="cover"></edu-image>
          </div>
          <div class="info">
            <div class="name" @click="handlePath(item)">{{ item.title }}</div>
            <div class="desc">{{ item.abstract }}</div>
            <el-row type="flex" align="middle" justify="space-between">
              <div class="time">
                {{ item.publish_time | parseTime('{y}-{m}-{d}') }}
              </div>
              <div class="see"><i class="el-icon-view el-icon--left"></i>{{ item.read_count }}</div>
            </el-row>
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import HomeTitle from './homeTitle.vue'
export default {
  components: {
    HomeTitle
  },
  props: {
    newsList: {
      type: Array,
      default: null
    }
  },
  methods: {
    handleMore() {
      this.$router.push({ path: '/topic' })
    },
    handlePath(item) {
      this.$router.push({
        path: '/topic/details',
        query: {
          id: item.id
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.info {
  padding: 30px 15px;
  .item {
    height: 332px;
    border: 1px solid $border-color-divider;
    border-radius: 4px;
    .picture {
      height: 0;
      padding-top: 180px;
      position: relative;
      cursor: pointer;
      .el-image {
        width: 100%;
        height: 100%;
        position: absolute;
        left: 0;
        top: 0;
      }
    }
    .info {
      padding: 15px 10px;
    }
    .name {
      color: $text-color-import;
      font-size: 18px;
      cursor: pointer;
      @include ellipsisLine(1);
    }
    .desc {
      margin-top: 15px;
      margin-bottom: 15px;
      height: 44px;
      color: $text-color-secondary;
      font-size: 14px;
      line-height: 22px;
      @include ellipsisLine(2);
    }
    .time {
      color: #b7bac1;
      font-size: 14px;
    }
    .see {
      color: #b7bac1;
      font-size: 14px;
    }
  }
}
</style>
